package com.freedom.admin.domain.service.impl;

import com.freedom.admin.domain.repository.RoleMenuRepository;
import com.freedom.admin.infrastructure.persistence.mapper.SysRoleMenuMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class RoleMenuRepositoryImpl implements RoleMenuRepository {

    private final SysRoleMenuMapper roleMenuMapper;

    @Override
    public void removeByRoleIds(List<Integer> roleIds) {
        roleMenuMapper.deleteByRoleIds(roleIds);
    }

    @Override
    public void addRoleMenu(Integer roleId, List<Integer> menuIds) {
        roleMenuMapper.insertRoleMenu(roleId, menuIds);
    }

    @Override
    public List<Integer> findMenuIdsByRoleId(Integer roleId) {
        return roleMenuMapper.selectMenuIdsByRoleId(roleId);
    }

    @Override
    public void removeRoleMenu(Integer roleId, List<Integer> menuIdList) {
        roleMenuMapper.deleteRoleMenu(roleId, menuIdList);
    }
}
